package com.tiancheng.trade.authserver.component.login.impl;


import com.tiancheng.trade.authserver.enums.LogInTypeEnum;
import com.tiancheng.trade.authserver.enums.ThirdPlatformEnums;
import com.tiancheng.trade.authserver.enums.TokenTypeEnum;
import com.tiancheng.trade.authserver.service.IAuthApplicationService;
import com.tiancheng.trade.authserver.vo.UserLoginInVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * oauth2 密码登录
 */
@Slf4j
@Component("oauth2PasswordLogin")
public class Oauth2PasswordLogin extends PasswordSignInHandler {
    @Resource
    protected IAuthApplicationService applicationService;

    @Override
    protected void paramValidate(UserLoginInVO param, boolean checkCertificate) {
        String clientId = param.getClientId();
        super.paramValidate(param, checkCertificate);
        param.setThirdPlatform(ThirdPlatformEnums.tiancheng);
        param.setTokenType(TokenTypeEnum.oauth2_password);
        param.setClientId(clientId);
    }


    @Override
    public LogInTypeEnum getHandleType() {
        return LogInTypeEnum.Oauth2Password;
    }
}
